#ifndef _HashMethods_H_
#define _HashMethods_H_
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <string>
#include "md5.h"
using namespace std;
class HashMethods{
public:
	string getMD5HashVal(const char * instr);
};
string HashMethods::getMD5HashVal(const char *instr)
{
	int i;
	long hash = 0;
	ostringstream oss;
	unsigned char digest[16];
	md5_state_t md5state;
	md5_init(&md5state);
    	md5_append(&md5state, (const unsigned char *)instr, strlen(instr));
    	md5_finish(&md5state, digest);
    	for(i = 0; i < 4; i++)
    	{
    		hash += ((long)(digest[i*4 + 3]&0xFF) << 24)
    		| ((long)(digest[i*4 + 2]&0xFF) << 16)
    		| ((long)(digest[i*4 + 1]&0xFF) <<  8)
    		| ((long)(digest[i*4 + 0]&0xFF));
    	}
    	oss<<hash;
	return oss.str();
}

#endif 